$(document).ready(function(){ 

	 //关闭AJAX相应的缓存
	$.ajaxSetup ({cache: false});

	$(window).scroll(function() {  
        if ($(this).scrollTop() > 1) { 
            $("#gotoTop").fadeIn();  
        } else {  
            $("#gotoTop").fadeOut();  
        }  
    });  
    $("#gotoTop").click(function() {  
        $("html,body").animate({  
            scrollTop: 0  
        }, 400); 
        return false;  
    });
	$("form img.captcha").click(function (){
		$(this).attr('src','/captcha.html?_='+Math.random())
	})
	

		if($(".FormValidate"))bodyForm(".FormValidate");

		$('#searchForm').Validform({tiptype:4});

		if($("#feedback-tab")){
			$("#feedback-tab").find(".tab").each(function(){
				$(this).click(function(){
					$(this).parent().find(".tab").removeClass("active");
					var rel= $(this).attr("rel");
					if(rel>0){
						$(this).addClass("active");
						$("#feedbackTypeid").val(rel);
						if(rel==4){
							var tips = "请您写下型号、品牌、数量、要求等，我们会第一时间帮您确认。剩下的，就交给我们就好了……";
						}else{
							var tips = "欢迎您申请商务合作，请填写您的联系信息，我们将在第一时间联系您。";
						}
						$("#feedback_desc").attr("placeholder",tips);
						
					}
				})
			})

		}
		//快速询价
		if($("#fastRFQ")){
			$("#fastRFQ").find("span").each(function(){
				$(this).click(function(){
					var $this = $(this);
					var $note = $("#fastRFQ_note").val();
					if($note){
						$note += ','+$this.html();
					}else{
						$note = $this.html();
					}
					$("#fastRFQ_note").val($note);
				})
			})
			$("#fastRFQ").hover(
			  function () {
				$(this).show();
			  },
			  function () {
				$(this).hide();
			  }
			);
		}
		//快速购买
		if($("#fastCart")){
			$("#fastCart").hover(
			  function () {
				$(this).show();
			  },
			  function () {
				$(this).hide();
			  }
			);
		}

		
		//Ajax 加载购物车
		if ($('#ajaxCartNum').size()>0)
		{	
			var $url = $('#ajaxCartNum').data("url");
			$('#ajaxCartNum').load($url);
		}


		//分类tree
		$("#treelit").hover(function(){
			var $this = $(this);
			$this.addClass("tree-selected");
			$this.find(".treebox").show();
		},function () {
			var $this = $(this);
			$this.removeClass("tree-selected");
			$this.find(".treebox").hide();
		});

		$("#tag_attr").find("h2").each(function(i){
			$(this).hover(function(){
				var $this = $(this);
				$("#tag_attr").find("h2").removeClass("h2bg");
				$(this).addClass("h2bg");
				$(".tonginfo").hide();
				$("#tag_attr_"+i).show();
			})
		})

		$(".treebox").find("li.treeli").each(function(){
			var $this = $(this);
			$this.hover(function(){
				$this.addClass("tree-selected");
				$this.find(".treeul").show();
			},function () {
				$this.removeClass("tree-selected");
				$this.find(".treeul").hide();
			});
		});

		//添加删除行
		$(".edittable").find(".addtr").click(function(){
			var $num = $(".edittable tr").length-1;
			var $tab =  $(this).parents("tr").clone();
			$tab.find("input").val("");
			$tab.find(".addtr").val("删除一行").attr("class","minTsubmit deltr");


			$(".edittable").append($tab).find(".deltr").click(function(){
				$(this).parents('tr').remove();
			});
		});


	/*广告滚动效果*/ 
	var len = $(".num > li").length;  
    var index = 0;  
    var adTimer;
    $(".num li").mouseover(function() {  
		index = $(".num li").index(this);  
		showImg(index);  
	}).eq(0).mouseover();  
    
	//滑入 停止动画，滑出开始动画.  
	$('.index_ad').hover(function() {
		clearInterval(adTimer);  
	}, function() {  
		adTimer = setInterval(function() {  
			showImg(index); 
			index++;  
			if (index == len) { index = 0; }  
		}, 2000);  
    }).trigger("mouseleave");  
})

// 通过控制top ，来显示不同的幻灯片  
function showImg(index) {  
	var adHeight = $(".index_ad").height();  
	//$(".slider").stop(true, false).animate({ top: -adHeight * index }, 1000);   //翻滚效果  
	$(".slider").css("top", -adHeight * index);     //跳转效果  
	$(".num li").removeClass("on").eq(index).addClass("on");  
}  



//收藏页面   
function FavoriteSite(sURL, sTitle) {   
	sURL = encodeURI(sURL);
	try{
		window.external.addFavorite(sURL, sTitle);
	}catch(e){
		try{
			window.sidebar.addPanel(sTitle, sURL, "");//firefox
		}catch (e) {
			alert("添加收藏失败，请使用 Ctrl+D 进行收藏");
		}   
	}
}


/* *
 * 数量是否合法
 */
function bodyForm(divid){

	$(divid).Validform({tiptype:4,ajaxPost:true
		,callback:function(data){
			if(data.status=="Y"){
				if(data.rel && $('#'+data.rel))
				{
					closeDialog();
					if(data.html){
						$('#'+data.rel).html(data.html);
					}else if(typeof(data.text)!="undefined"){
						$('#'+data.rel).val(data.text);
					}else{
						$('#'+data.rel).html(data.message);
					}
				}
				if(data.cartNum){
					$('#ajaxCartNum').html(data.cartNum);
				}

				if(data.url){
					if(data.dialog){
						showDialog(data.url);
					}else{
						sysDialog(data);
						window.location.href= data.url;
					}
				}else{
					sysDialog(data);
				}
			}else if(data.rel && $('#'+data.rel)){
				$('#'+data.rel).html(data.message);
			}else{
				alert(data.message);
			}	
			return false;
		}

	});  

}

//系统提示
function sysDialog(data) {
	if(typeof data === 'object'){
		if(data.message){
			var $html = '<div class="theme-poptit"><span class="dtitle">系统提示</span><a href="javascript:void(0);" onclick="closeDialog();" title="关闭" class="close">×</a></div>';
			$html += '<div class="theme-popbod sys_msg">'+data.message+'</div>'; 
			
			$('.theme-popover-mask').fadeIn(50);
			$('.theme-popover').html($html).show();
			var bh = $(".theme-popover").height();
			var bw = $(".theme-popover").width();
			$(".theme-popover").css({"margin-left":(0-bw/2),"margin-top":(0-bh/2)});
			if(data.sleep){
				setTimeout(function () {closeDialog();}, data.sleep);
			}else{
				setTimeout(function () {closeDialog();}, 1200);
			}
		}else{
			closeDialog();
		}
	}
}




//URL 加载弹窗
function showDialog(url) {
	if(url){
		$('.theme-popover-mask').fadeIn(50);
		$('.theme-popover').show();
		var bh = $(".theme-popover").height();
		var bw = $(".theme-popover").width();
		$(".theme-popover").css({"margin-left":(0-bw/2),"margin-top":(0-bh/2)});
			let json = {
						html:
					"<div class=\"theme-poptit\"><span class=\"dtitle\">用户登录</span><a href=\"javascript:void(0);\" onclick=\"closeDialog();\" title=\"关闭\" class=\"close\">×</a></div>\r\n<div class=\"theme-popbod\">\r\n  <div class=\"userTable\" style=\"width:420px;\">\r\n    <form action=\"https://www.zhaoxin.cn/users/login.html\" method=\"post\" class=\"FormValidate\">\r\n        <table class=\"noborder\">\r\n          <tr>\r\n          <th width=\"80\">账  号：</th>\r\n          <td><input name=\"username\"  id=\"slogin_mobile\" type=\"text\" value=\"\" size=\"25\" placeholder=\"手机或邮箱\" class=\"inputBg\" datatype=\"m|e\" nullmsg=\"不能为空\" errormsg=\"账号错误！\"></td>\r\n          </tr>\r\n          <tr>\r\n          <th>密  码：</th>\r\n          <td><input name=\"password\" type=\"password\" size=\"25\" class=\"inputBg\" datatype=\"*6-15\" nullmsg=\"不能为空\" errormsg=\"6~15位\" /></td>\r\n          </tr>\r\n          <tr>\r\n          <td>&nbsp;</td>\r\n          <td>\r\n          <label><input type=\"checkbox\" value=\"1\" name=\"remember\" />自动登录</label>\r\n          <a class=\"f6\" href=\"/users/password.html\" style=\"margin-left:80px;\">忘记密码？</a>\r\n          </td>\r\n          </tr>\r\n          <tr>\r\n          <td>&nbsp;</td>\r\n          <td>\r\n          <input type=\"hidden\" name=\"ajax\" value=\"1\" />\r\n          <input type=\"hidden\" name=\"back_act\" value=\"https://www.zhaoxin.cn/\" />\r\n          <input type=\"submit\" name=\"submit\" value=\"登录\" class=\"Hsubmit\" style=\"margin-left:30px;width:120px;\" />     \r\n          <div id=\"login_member_error\" ></div>\r\n          </td>\r\n          </tr>\r\n        </table>\r\n    <input type=\"hidden\" name=\"form_hash\" value=\"dcf08446_6c5ebb\" /></form>\r\n  </div>\r\n</div>\r\n<div class=\"theme-popbom\"><a href=\"/users/register.html\">免费注册</a></div>"
		}
			$(".theme-popover").html(json.html);
			bodyForm(".theme-popover .FormValidate");
			var bh = $(".theme-popover").height();
			var bw = $(".theme-popover").width();
			$(".theme-popover").css({"margin-left":(0-bw/2),"margin-top":(0-bh/2)});
	}else{
		$('.theme-popover-mask').fadeOut(50);
		$('.theme-popover').hide();
	}
	return false;
}


function showDialog1(url) {
	if(url){
		$('.theme-popover-mask').fadeIn(50);
		$('.theme-popover').show();
		var bh = $(".theme-popover").height();
		var bw = $(".theme-popover").width();
		$(".theme-popover").css({"margin-left":(0-bw/2),"margin-top":(0-bh/2)});
		let json = {
			html:"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<div class=\"theme-poptit\"><span class=\"dtitle\">新增收货地址</span><a href=\"javascript:void(0);\" onclick=\"closeDialog();\" title=\"关闭\" class=\"close\">×</a></div>\r\n\t<div class=\"theme-popbod userTable\">\r\n\t\t<form action=\"../orders/address.html\" method=\"post\" class=\"FormValidate\">\r\n\t\t\t<table class=\"noborder\" style=\"width:560px;\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th>公司名称：</th>\r\n \t<td colspan=\"3\" bgcolor=\"#ffffff\"><input name=\"user-company\" type=\"text\" class=\"inputBg\" value=\"\" size=\"40\" /> (打印合同)</td>\r\n </tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th class=\"need\" width=\"100\"><font color=\"red\">*</font> 联系人：</th>\r\n\t\t\t\t\t<td width=\"160\"><input name=\"user-contact\" type=\"text\" class=\"inputBg\" value=\"\" size=\"15\" datatype=\"s\" nullmsg=\"\" errormsg=\"\"/></td>\r\n\t\t\t\t\t<th width=\"60\">电话：</th>\r\n\t\t\t\t\t<td><input name=\"user-tel\" type=\"text\" class=\"inputBg\" value=\"\" size=\"15\"/></td>\r\n </tr>\r\n <tr>\r\n\t\t\t\t\t<th><font color=\"red\">*</font>手机：</th>\r\n\t\t\t\t\t<td><input name=\"user-mobile\" type=\"text\" class=\"inputBg\" value=\"\" size=\"15\" datatype=\"m\" nullmsg=\"\" errormsg=\"\" /></td>\r\n\t\t\t\t\t<th>邮政编码：</th>\r\n\t\t\t\t\t<td><input name=\"user-zipcode\" type=\"text\" class=\"inputBg\" value=\"\" size=\"15\"/></td>\r\n\t\t\t\t<tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th><font color=\"red\">*</font> 所在区域：</th>\r\n\t\t\t\t\t<td colspan=\"3\"><select name=\"user-area[]\" onchange=\"getRegion(this, 2, 'selCities')\" class=\"selectBg w120\" datatype=\"*\">\r\n <option value=\"\">请选择</option>\r\n <option value=\"\" >请选择</option><option value=\"0-1-25-\" >上海</option><option value=\"0-1-30-\" >云南</option><option value=\"0-1-19-\" >内蒙古</option><option value=\"0-1-2-\" >北京</option><option value=\"0-1-35-\" >台湾</option><option value=\"0-1-15-\" >吉林</option><option value=\"0-1-26-\" >四川</option><option value=\"0-1-27-\" >天津</option><option value=\"0-1-20-\" >宁夏</option><option value=\"0-1-3-\" >安徽</option><option value=\"0-1-22-\" >山东</option><option value=\"0-1-23-\" >山西</option><option value=\"0-1-6-\" >广东</option><option value=\"0-1-7-\" >广西</option><option value=\"0-1-29-\" >新疆</option><option value=\"0-1-16-\" >江苏</option><option value=\"0-1-17-\" >江西</option><option value=\"0-1-10-\" >河北</option><option value=\"0-1-11-\" >河南</option><option value=\"0-1-31-\" >浙江</option><option value=\"0-1-9-\" >海南</option><option value=\"0-1-13-\" >湖北</option><option value=\"0-1-14-\" >湖南</option><option value=\"0-1-34-\" >澳门</option><option value=\"0-1-5-\" >甘肃</option><option value=\"0-1-4-\" >福建</option><option value=\"0-1-28-\" >西藏</option><option value=\"0-1-8-\" >贵州</option><option value=\"0-1-18-\" >辽宁</option><option value=\"0-1-32-\" >重庆</option><option value=\"0-1-24-\" >陕西</option><option value=\"0-1-21-\" >青海</option><option value=\"0-1-33-\" >香港</option><option value=\"0-1-12-\" >黑龙江</option>     </td>\r\n\t\t\t\t</tr>\r\n <tr>\r\n\t\t\t\t\t<th><font color=\"red\">*</font> 详细地址：</th>\r\n\t\t\t\t\t<td colspan=\"3\"><input name=\"user-address\" type=\"text\" class=\"inputBg\" datatype=\"s\" nullmsg=\"\" errormsg=\"\" value=\"\" size=\"50\" /></td>\r\n\t\t\t\t</tr>\t\t\t\t\r\n <tr>\r\n \t<td height=\"50\" colspan=\"2\" align=\"right\" >\r\n\t\t\t\t\t\t<input name=\"id\" type=\"hidden\" value=\"\" />\r\n\t\t\t\t\t\t<input type=\"submit\" name=\"submit\"  onclick=\"closeDialog()\"    class=\"Tsubmit\" value=\"提交保存\"/>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t\t<td colspan=\"2\" align=\"center\">\r\n\t\t\t\t\t\t<label><input type=\"checkbox\" name=\"user-default\" value=\"1\" > 设置为默认地址</label>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n </table>\r\n\t\t<input type=\"hidden\" name=\"form_hash\" value=\"f22c89a8_1307fe\" /></form>\r\n</div>"
		}
			$(".theme-popover").html(json.html);
			bodyForm(".theme-popover .FormValidate");
			var bh = $(".theme-popover").height();
			var bw = $(".theme-popover").width();
			$(".theme-popover").css({"margin-left":(0-bw/2),"margin-top":(0-bh/2)});
	}else{
		$('.theme-popover-mask').fadeOut(50);
		$('.theme-popover').hide();
	}
	return false;
}
		
//关闭灰色 jQuery 遮罩
function closeDialog() {
	$('.theme-popover-mask').fadeOut(50);
	$('.theme-popover').hide().html('<div class="load">正在加载，请稍后....</div>');
	return false;
} 

//快捷询盘
function showRFQ(odj,sw){
	if(sw){
		var $this = $(odj);
		if($this.attr("rel")){
			var json = $.parseJSON($this.attr("rel"));
			$("#fastRFQ").find("input[name='code']").val(json.cd);
			$("#fastRFQ").find("input[name='name']").val(json.xh);
			$("#fastRFQ").find("input[name='brand']").val(json.pp);
			$("#fastRFQ").find("input[name='fengz']").val(json.fz);
			$("#fastRFQ").find("input[name='stock']").val(json.kc);
			$("#fastRFQ").find("input[name='jiage']").val(json.jg);
			$("#fastRFQ").find("input[name='number']").val("");
			$("#fastRFQ").find("input[name='price']").val("");
			$this.parents("tr").css({"background-color":"#FFECE0"});
		}
		var offset = $this.position(true);
		if(sw==2){
			$("#fastRFQ").css({"display":"block","top":(offset.top-170),"left":(offset.left-215)});
		}else{
			$("#fastRFQ").css({"display":"block","top":(offset.top-4),"left":(offset.left-500)});
		}
	}else{
		$('#fastRFQ').hide();
		$(odj).parents("tr").css({"background-color":"#FFF"});
	}
}



/* *
 * 购买数量
 */
function changePrice(odj){
	var $this = $(odj);
	var $num = $this.val();
	$num = isNaN(parseInt($num)) ? 1 : parseInt($num.replace(/[^\d.]/g,''));
	var price = 0;
	var amount = 0;
	$("#J_PriceList").find(".number").each(function(i){
		var number = $(this).html();
 			number = isNaN(parseInt(number)) ? 0 : parseInt(number.replace(/[^\d.]/g,''));
		if($num>=number){
			price = $(this).attr("price");
			price = isNaN(parseFloat(price)) ? 0 : parseFloat(price.replace(/[^\d.]/g,''));
			amount = parseFloat(price*$num).toFixed(2);
		}
	});

	$("#J_StrPrice").html("￥"+price);
	var Jamount = (amount>0) ? "￥"+amount :"申请价格";
	$("#J_StrAmount").html(Jamount);
}


/* *
 * 添加收藏
 */
function addCollect(code){
	if(code){
		$.getJSON("../carts/collect.html", {qs:code}, function(result){
			if(result.status == "Y"){ 
				if(result.url) location.href = result.url;
			}
			if(result.message)	sysDialog(result);
		});
	}
	return false;
}

/* *
 * 清空浏览历史
 */
function clearHistory(){
	$.getJSON("cart.php", {act:"clear_history"}, function(){
		$('#history_div').hide();
	});
	return false;
}


/* *
 * 更改询盘状态 
 */
function EnquiryStatus(odj,did,status)
{
	var $this = $(odj);
	var data = {act:"inquiry"};
	data['id'] = did;
	if(status==3){
		data['op'] = 'urgent';
	}else if(status==1){
		data['op'] = 'save';
	}else if(status==2){
		data['op'] = 'cancel';
	}else if(status==0){
		data['op'] = 'del';
	}
	if(data && did){
		$.get('../users/inquiry.html', data, function(result){
			if(result=="Y"){
				$this.parents("table").fadeOut("slow");
			}
		});
	}
	return false;

}

//快捷询盘
function showCart(odj,sw){
	if(sw){
		var $this = $(odj);
		if($this.attr("rel")){
			var code = $this.attr("rel");
			$("#fastCart_qs").val(code);
		}
		var offset = $this.position(true);
		$("#fastCart").css({"display":"block","top":(offset.top),"left":(offset.left-162)});
	}else{
		$('#fastCart').hide();
	}
}

/* *
 * 添加商品到购物车 
 */
function addToCart(odj,code,type)
{
	if(code){
		if(type){
			var number = parseInt($("#buyNumber"+odj).val());
		}else{
			var number = (isNaN(parseInt(odj)) || $(odj).val());
		}
		$.getJSON('../carts/add.html', {qs:code,qty:number}, function(result){
			if(result.status == "Y"){
				if(result.url) location.href = result.url;
				$('#ajaxCartNum').html(result.cartNum);
			}
			if(result.message)	sysDialog(result);
		});
	}
	return false;
}


/* *
 * 更新购物车商品 
 */
function UpdateCart(odj,recId)
{
	var $box = $(odj).parents("tr");
	var $qty  = $(odj).val();
	$.getJSON("../carts/edit.html", {id:recId,qty:$qty}, function(result){
		if(result.status == "Y"){
			if(result.url) location.href = result.url;
			$box.find("td.price").html(result.price);
			$box.find("td.amount").html(result.amount);
			$('#SUM_cartAmount').html(result.total);
		}
		if(result.message)	sysDialog(result);
	});
}

/* *
 * 更新购物车商品 
 */
function DeleteCart(odj,recId)
{
	var $box = $(odj).parents("tr");
	//直接移除Dom层
	$box.remove();
}

/* *
 * 更新购物车商品 
 */
function upNuber(odj,Mult,ALG)
{
	var $box = $("#"+odj);
	var num  = parseInt($box.val());
	if(Mult>0){
		if(ALG=="+"){
			$box.val(num+Mult);
			changePrice($box);
		}else if(num>Mult){
			$box.val(num-Mult);
			changePrice($box);
		}
	}
}

/* *
 * 选择地区
 */
function getRegion(odj,level,selName){

	var parent = $(odj).find("option:selected").val();
	var $this = $('#'+selName);
	if(parent && $this){
		$.getJSON("../region.html", {parent:parent,level:level}, function(json){
			if(json){ 
				var html = '';
				$.each(json, function(i){
					if (json[i] && json[i].length > 1){
						html += '<option value="'+json[i][0]+'">' + json[i][1] + '</option>';
					}
				});
				$this.removeAttr("disabled").empty().append(html);
				if(level==2){
					var html = '<option value="">请选择</option>';
					$('#selDistricts').empty().append(html).attr("disabled","disabled"); 
				}
			}else{
				$this.attr("disabled","disabled"); 
			}
		});
	}
	return false;
}




//获取验证码
function getVerify(odj,mobileID)
{
	var $this = $(odj);
	if($this.val() != "获取验证码"){
		return false;
	}
	var mobile = $("#mobile_"+mobileID).val();
	var ajaxurl = $this.attr('ajaxurl');
	
	if(checkPhoneNum(mobile)==false && mobileID != "mail"){
		alert("请填写正确的手机号码！");
		return false;
	}
	
	$this.val('120 秒');
	$.post(ajaxurl, {val:mobile,act:mobileID},function(msg){
		if(msg=='Y'){
			setInterval(function() {
				var sec = parseInt($this.val().replace(/[^0-9]/g,''));
				if(sec > 0){
					sec--;
					$this.val(sec+' 秒');
				}else{
					$this.val('获取验证码');
				}
			}, 1000);  
		}else{
			$this.val('获取验证码');
			alert(msg);
		}
	});
}

		//全选
function allchecked(obj,ID){
	var $this = $(ID);
	if($(obj).prop("checked")){
		$this.find(":checkbox").prop("checked",true);
	}else{
		$this.find(":checkbox").prop("checked",false);
	}
}
/**
 * 验证电话号码（手机号码+电话号码）
 * @param obj
 * @returns {Boolean}
 */
function checkPhoneNum(obj){
    if(/^((\d{3}-\d{8}|\d{4}-\d{7,8})|(1[3|5|7|8][0-9]{9}))$/.test(obj)){
        return true;
    }
	return false;
}

//订单选择
function OrderSelect(odj,id,rel,text,boxid)
{
	var $this = $(odj);
	$this.parents(".orders-list").find(".orders-item").removeClass("selected");
	$this.addClass("selected");
	$('#'+rel).val(id);
	if(text){
		if($this.attr("rel")){
			$('#'+rel+"_text").html($this.attr("rel"));
		}else{
			$('#'+rel+"_text").hide();
			if(text==1){
				$('#'+rel+"_text").show();
			}
		}
//		if(rel=="invoiceId" && $this.attr("url")){
//			showDialog($this.attr("url"));
//		}
	}
	if(boxid){
		$('.'+rel).hide();
		$('#'+boxid).show();
	}

}

jQuery.ljsGlasses = {
	pcGlasses:function(_obj){
		var _box = $("#"+_obj.boxid);
		var _sum = $("#"+_obj.sumid);
		var _last,_next;
		var _imgarr = _box.find("img");
		var _length = _imgarr.length;
		var _index = 0;
		var _arr = new Array();
		_sum.append("<p style='position:absolute;left:0;top:0;'></p>");
		var _sumbox = _sum.find("p");

		for(var i=0;i<_length;i++){
			_arr[i] = new Array();
			_arr[i][0] = _imgarr.eq(i).attr("src");
			_arr[i][1] = _imgarr.eq(i).attr("width");
			_arr[i][2] = _imgarr.eq(i).attr("height");
			var _scale = _arr[i][1]/_arr[i][2];
			if(_scale == 1){
				_arr[i][3] = _obj.boxw;//width
				_arr[i][4] = _obj.boxh;//height
				_arr[i][5] = 0;//top
				_arr[i][6] = 0;//left
				_arr[i][7] = _obj.boxw/2;
				_arr[i][8] = _obj.boxw*2;//width
				_arr[i][9] = _obj.boxh*2;//height
				_sumbox.append("<span><img src='"+_imgarr.eq(i).attr("src")+"' width='"+_obj.sumw+"' height='"+_obj.sumh+"' /></span>");
			}
			if(_scale > 1){
				_arr[i][3] = _obj.boxw;//width
				_arr[i][4] = _obj.boxw/_scale;
				_arr[i][5] = (_obj.boxh-_arr[i][4])/2;
				_arr[i][6] = 0;//left
				_arr[i][7] = _arr[i][4]/2;
				_arr[i][8] = _obj.boxh*2*_scale;//width
				_arr[i][9] = _obj.boxh*2;//height
				var _place = _obj.sumh - (_obj.sumw/_scale);
				_place = _place/2;
				_sumbox.append("<span><img src='"+_imgarr.eq(i).attr("src")+"' width='"+_obj.sumw+"' style='top:"+_place+"px;' /></span>");
			}
			if(_scale < 1){
				_arr[i][3] = _obj.boxh*_scale;//width
				_arr[i][4] = _obj.boxh;//height
				_arr[i][5] = 0;//top
				_arr[i][6] = (_obj.boxw-_arr[i][3])/2;
				_arr[i][7] = _arr[i][3]/2;
				_arr[i][8] = _obj.boxw*2;//width
				_arr[i][9] = _obj.boxw*2/_scale;
				var _place = _obj.sumw - (_obj.sumh*_scale);
				_place = _place/2;
				_sumbox.append("<span><img src='"+_imgarr.eq(i).attr("src")+"' height='"+_obj.sumh+"' style='left:"+_place+"px;' /></span>");
			}
		}
		_imgarr.remove();

		_sum.append("<div style='clear:both;width:100%;'></div>");
		var _sumarr = _sum.find("span");
		var _sumimg = _sum.find("img");
		_sumarr.eq(_index).addClass(_obj.sumsel);
		var _border = _obj.sumborder*2 + _obj.sumh;
		var _sumwidth = (_border+_obj.sumi)*_obj.sums;
		var _sumboxwidth = (_border+_obj.sumi)*_length;
		_sum.css({
			"overflow":"hidden",
			"height":_border+"px",
			"width":_sumwidth+"px",
			"position":"relative"
		});
		_sumbox.css({
			"width":_sumboxwidth+"px"
		});
		_sumarr.css({
			"float":"left",
			"margin-left":_obj.sumi+"px",
			"width":_obj.sumw+"px",
			"height":_obj.sumh+"px",
			"overflow":"hidden",
			"position":"relative"
		});
		_sumimg.css({
			"max-width":"100%",
			"max-height":"100%",
			"position":"relative"
		});

		_box.append("<div style='position:relative;'><b style='display:block;'><img style='display:block;' src='' /></b><span style='position:absolute;left:0;top:0;display:none;z-index:5;'></span></div><p style='position:absolute;overflow:hidden;top:0;display:none;'><img style='max-width:none;max-height:none;position:relative;left:0;top:0;' src='' /></p>");
		var _glass = _box.find("span");
		var _boximg = _box.find("b img");
		var _imgout = _box.find("div");
		var _showbox = _box.find("p");
		var _showimg = _box.find("p img");

		_box.css({
			"width":_obj.boxw+"px",
			"height":_obj.boxh+"px",
			"position":"relative"
		});
		var _showboxleft = _obj.boxw + 10;
		_showbox.css({
			"width":_obj.boxw+"px",
			"height":_obj.boxh+"px",
			"left":_showboxleft+"px"
		});

		var imgPlaces = function(){
			_showimg.attr("src",_arr[_index][0]);
			_boximg.attr("src",_arr[_index][0]);
			_boximg.css({
				"width":_arr[_index][3]+"px",
				"height":_arr[_index][4]+"px"
			});
			_imgout.css({
				"width":_arr[_index][3]+"px",
				"height":_arr[_index][4]+"px",
				"top":_arr[_index][5]+"px",
				"left":_arr[_index][6]+"px",
				"position":"relative"
			});
			_glass.css({
				"width":_arr[_index][7]+"px",
				"height":_arr[_index][7]+"px"
			});
			_showimg.css({
				"width":_arr[_index][8]+"px",
				"height":_arr[_index][9]+"px"
			});

		};
		imgPlaces();

		_imgout.mousemove(function(e){
			var _gl_w = _glass.width()/2;
			var _maxX = _imgout.width() - _gl_w;
			var _maxY = _imgout.height() - _gl_w;
			var _moveX = 0,_moveY = 0;
			var _nowX = e.pageX - _imgout.offset().left;
			var _nowY = e.pageY - _imgout.offset().top;
			var _moveX = _nowX-_gl_w,_moveY = _nowY-_gl_w;

			if(_nowX <= _gl_w){ _moveX = 0; }
			if(_nowX >= _maxX){ _moveX = _maxX-_gl_w; }
			if(_nowY <= _gl_w){ _moveY = 0;}
			if(_nowY >= _maxY){ _moveY = _maxY-_gl_w;}
			_glass.css({"left":_moveX+"px","top":_moveY+"px"});

			var _imgX = -_moveX*_showbox.width()/_glass.width();
			var _imgY = -_moveY*_showbox.width()/_glass.width();
			_showimg.css({"left":_imgX+"px","top":_imgY+"px"});

		});//mouse END

		_imgout.mouseenter(function(){
			_glass.css("display","block");
			_showbox.css("display","block");
		});
		_imgout.mouseleave(function(){
			_glass.css("display","none");
			_showbox.css("display","none");
		});

		//列表部分
		var _nextbtn = $("#"+_obj.nextid);
		var _lastbtn = $("#"+_obj.lastid);
		var _moveindex = 0;//索引移动

		var _sumListMove = function(){
			var _leftmove = -_moveindex*(_border+_obj.sumi);
			if(_sumbox.is(":animated")){_sumbox.stop(true,true);}
			_sumbox.animate({left:_leftmove+"px"},300);
			_sumarr.eq(_index).addClass(_obj.sumsel).siblings().removeClass(_obj.sumsel);
			imgPlaces();
		};//fun END

		if(_length <= _obj.sums){
			var _place = (_obj.sums-_length)*_border/2;
			// _sumbox.css("left",_place+"px");
			_nextbtn.click(function(){
				_index++;
				if(_index >= _length){ _index=_length-1;}
				_sumarr.eq(_index).addClass(_obj.sumsel).siblings().removeClass(_obj.sumsel);
				imgPlaces();
			});
			_lastbtn.click(function(){
				_index--;
				if(_index <= 0){ _index=0;}
				_sumarr.eq(_index).addClass(_obj.sumsel).siblings().removeClass(_obj.sumsel);
				imgPlaces();
			});
		}else{
			var _maxNum = _length-_obj.sums;
			_nextbtn.click(function(){
				_moveindex++;
				if(_moveindex >= _maxNum){ _moveindex=_maxNum; }
				if(_index <= _moveindex){ _index=_moveindex;}
				_sumListMove();
			});
			_lastbtn.click(function(){
				_moveindex--;
				if(_moveindex <= 0){ _moveindex=0;}
				if(_index >= _moveindex+_obj.sums){ _index=_moveindex+_obj.sums-1;}
				_sumListMove();
			});
		}//if END

		_sumarr.hover(function(){
			_index = $(this).index();
			_sumarr.eq(_index).addClass(_obj.sumsel).siblings().removeClass(_obj.sumsel);
			imgPlaces();
		});

	}//pcGlasses END
}//ljsGlasses END